home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
basic
/
vidbasic.zip
/
VCLEARA.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-11-29
|
16KB
|
545 lines
;«RM83»«TS8,16,24,32,40,48»
; Updated 11/20/90
;============================================================================
; Copyright (C) Copr. 1990 by Sidney J. Kelly
; All Rights Reserved.
; Sidney J. Kelly
; 150 Woodhaven Drive
; Pittsburgh, PA 15228
; home phone 412-561-0950 (7pm to 9:30pm EST)
;============================================================================
DOSSEG
.MODEL MEDIUM, BASIC
.data
;external data so all video routines can access
EVEN
EXTRN B$DVIDEOSEG:WORD
EXTRN B$DVIDEOPORT:WORD
EXTRN B$DVIDEOINSTL:BYTE
.code
INCLUDE NOWAIT.INC
EXTRN Get_Adapter:FAR
comment |
Calc_DI_Offset_Addr macro
;; standard routine
;; Note destroys AX, BX, CL
;; ;8086 ;80286
Mov AX,CurrRow ;14 ;5
Dec AX ;3 ;2 ;;change from 1-25 to 0-24
Mov cl,160 ;4 ;2
Mul cl ;77 ;13 ;;multiply CurrRow by 160
Mov BX,BegCol ;14 ;5 ;;get starting column
Dec BX ;3 ;2 ;;change from 1-80 to 0-79
Shl BX,1 ;2 ;2 ;;multiply (CurrRow-1) by 2
Add AX,BX ;3 ;2 ;;get offset
Mov DI,AX ;3 ;2 ;;move to source index
endm ;---------
;123 ;35 ;;clocks
|
Calc_DI_Offset_Addr macro
;; This is slightly slower in the abstract
;; sense on a 80286. Cannot observe the difference
;; on a 8088 with a CGA because of delay waiting for retrace.
;; Though if have an 8088 with MONO or VGA/EGA it is faster
;;
;; Input: Nothing
;; Output: DI = Memory Offset
;; Destroys: CX,AX
;; Macro is used because inline code speeds routine
;; ;8088 ;80286
Xor CL, CL ;3 ;2 ;; Clear CL
Mov AX,CurrRow ;14 ;5 ;; get starting Row
Dec AX ;3 ;2 ;; change from 1-25 to 0-24
Mov CH, AL ;2 ;2 ;; CX = Row * 256
Shr CX, 1 ;2 ;2 ;; CX = Row * 128
Mov DI, CX ;2 ;2 ;; Store in DI
Shr DI, 1 ;2 ;2 ;; DI = Row * 64
Shr DI, 1 ;2 ;2 ;; DI = Row * 32
Add DI, CX ;3 ;2 ;; DI = (Row * 128)+(Row * 32)={Row*160}
Xor CH, CH ;3 ;2 ;; Clear CH register
Mov AX,BegCol ;14 ;5 ;; get starting Column
Dec AX ;3 ;2 ;; change from 1-80 to 0-79
Mov CL, AL ;2 ;2 ;; CX = Columns
Shl CX, 1 ;2 ;2 ;; Account for attribute
Add DI, CX ;3 ;2 ;; DI = (Row * 160) + (Col * 2)
;--------
endm ;60 ;36 ;; clocks
.code
;=====================Some data variables==================================
; Stored in Code segment to save space in DGROUP
EVEN
CurrRow DW 0 ;current CurrRow
BegCol DW 0 ;Starting Column
Num_Cols DW 0 ;words to copy per line
EndingRow DW 0 ;Ending Row
BACKCOLOR DW 0 ;store shadow color for MAKEBOXES
Color DB 0 ;Store color attribute
;===========================================================================
; DECLARE SUB
; CLEARAREA (BYVAL ULR%, BYVAL ULC%, BYVAL LRR%, BYVAL LRC%, BYVAL ATTRIB%)
; CALL CLEARAREA (ULR%, ULC%, LRR%, LRC%, ATTRIB%)
; Changes the attribute of an area on the screen in text mode
;===========================================================================
EVEN
CLEARAREA Proc FAR BASIC USES SI DI, \
ULR:Word, ULC:Word, LRR:Word, LRC:Word, ATTRIB:Word
comment |
Register usage when all done:
AH = Color attribute to change line to
AL = loading point for STOB, scratch.
CX = Number of characters to change on a line.
DX = Port for CGA video retrace check, if necessary.
0 means display is not a not a CGA display
DI = Offset of Screen for current character
ES = Segment of Video display, 0xB000 or 0xB800
BX = is used as a scratch variable register
DS & SI are not changed
|
Cmp B$DVIDEOINSTL,1
JE Didit
Call Get_Adapter ;determine the display type routine
Didit:
Mov ES,B$DVIDEOSEG ;store Video Segment in ES
Mov DX,B$DVIDEOPORT ;Get B$VDIDEOPORT
Mov BX,ULC ;get first column
Mov BegCol,BX
Mov BX,LRC ;get last column
Cmp BX,80
JBE @f
Mov BX,80 ; make sure right margin not > 80
; so no wrap around on left margin
@@:
Sub BX,BegCol ;subtract last column from first column
Inc BX ;add 1 to get number of columns to print
Mov Num_Cols,BX ;BX equals number of words to copy per line
Mov BX,LRR ;get last line
Mov EndingRow,BX
Mov BX,ULR ;get first line
Mov CurrRow,BX ;set current row to first line
Calc_DI_Offset_Addr ;calculate offset for line MACRO
Mov CX,Num_Cols ;load counter with words to copy
JCXZ Exit2 ;if CX is zero it's a zero length line
;so exit now
Mov BX,ATTRIB ;get the color ATTRIBUTE% that was passed
Mov AX,BX ;put it into AH for screen writing below
Mov Color,AL
Cld ;clear the direction flag to move data forward
EVEN
Main2:
Mov AH,Color ;get attribute & put it in AH
Mov AL,AH ;get attribute & put it in AL
Or DL,DL ;are we on a mono or EGA system?
JZ Mono2 ;yes, skip over the retrace stuff
EVEN
CGA2:
CLI ;prevent hardware interrupts
Wait_CGA_Retrace ;wait for retrace on CGA MACRO
Mov AL,AH ;get attribute & put it in AL
Inc DI
Stosb ;store the attribute
STI ;allow interrupts again
Loop CGA2 ;loop until CX is zero
Jmp Short Next_Line2
EVEN
Mono2:
Inc DI ;the increment before store allows one
;to change just the color attribute
Stosb ;store the attribute
Loop Mono2 ;loop until CX is zero
Next_Line2:
Mov AX,EndingRow
Cmp AX,CurrRow ;Are we done restoring window?
Je Exit2 ;exit if complete
INC CurrRow ;next line
Calc_DI_Offset_Addr ;compute new offset address MACRO
Mov CX,Num_Cols ;set counter to # of words to copy
JMP Short Main2 ;jump to print next line
Exit2:
Ret ;return skipping the passed parameters
CLEARAREA Endp
;===========================================================================
; DECLARE SUB BACKFILL
;(BYVAL ULR%, BYVAL ULC%, BYVAL LRR%, BYVAL LRC%, BYVAL ATTRIB%, BYVAL TEXTCHAR%)
; CALL BACKFILL(ULR%, ULC%, LRR%, LRC%, ATTRIB%, TEXT$)
; Fills the display area with a character and a fixed text attribute
;===========================================================================
EVEN
BACKFILL Proc FAR BASIC USES DI SI, \
ULR:Word, ULC:Word, LRR:Word, LRC:Word, ATTRIB:Word, TEXTS:Word
comment |
Register usage when all done:
AH = Color attribute to change line to
AL = loading point for text character.
CX = Number of characters to change on a line.
DX = Port for CGA video retrace check, if necessary.
0 means display is not a not a CGA display
DI = Offset of Screen for current character
ES = Segment of Video display, 0xB000 or 0xB800
BX = is used as a scratch variable register
SI = holds the text & character attribute
DS is not changed
|
Cmp B$DVIDEOINSTL,1
JE Didit1
Call Get_Adapter ;determine the display type routine
Didit1:
Mov ES,B$DVIDEOSEG ;store Video Segment in ES
Mov DX,B$DVIDEOPORT ;Get B$VDIDEOPORT
Mov BX,ULC ;get first column
Mov BegCol,BX
Mov BX,LRC ;get last column
Cmp BX,80
JBE @f
Mov BX,80 ; make sure right margin not > 80
; so no wrap around on left margin
@@:
Sub BX,BegCol ;subtract first column from last column
Inc BX ;add 1 to get number of columns to print
Mov Num_Cols,BX ;BX equals number of words to copy per line